package cn.iocoder.yudao.module.biz.controller.admin.receivables.domain;

import cn.iocoder.yudao.module.biz.controller.admin.contract.vo.ContractArchivePageReqVO;
import cn.iocoder.yudao.module.biz.controller.admin.invoice.domain.SanBizInvoiceManagement;
import cn.iocoder.yudao.module.biz.controller.admin.pay.domain.SanBizPaymentManagement;
import cn.iocoder.yudao.module.biz.dal.dataobject.contract.ContractArchiveDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.annotation.PostConstruct;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * 合同档案-分期收款
 * @TableName san_biz_contract_archive_receive_record
 */
@TableName(value ="san_biz_contract_archive_receive_record")
@Data
public class SanBizContractArchiveReceiveRecord implements Serializable {

    @Schema(description = "页码，从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1")
    @NotNull(message = "页码不能为空")
    @Min(value = 1, message = "页码最小值为 1")
    @TableField(exist = false)
    private Integer pageNo = 1;

    @Schema(description = "每页条数，最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    @NotNull(message = "每页条数不能为空")
    @Min(value = 1, message = "每页条数最小值为 1")
    @Max(value = 100, message = "每页条数最大值为 100")
    @TableField(exist = false)
    private Integer pageSize = 10;

    @TableField(exist = false)
    private Integer offset; // = (new BigDecimal(this.pageNo).subtract(new BigDecimal(1))).multiply(new BigDecimal(this.pageSize)).intValue();

    public Integer getOffset() {
        return (new BigDecimal(this.pageNo).subtract(BigDecimal.ONE))
                .multiply(new BigDecimal(this.pageSize)).intValue();
    }
    /**
     * 拓展监控大屏查询传入的月份
     */
    @Schema(description = "拓展监控大屏查询传入的月份", example = "2025-09")
    @TableField(exist = false)
    private String month;

    /**
     * id
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    @Schema(description = "合同档案id")
    private Long contractArchiveId;

    @Schema(description = "分期数")
    private Integer instalmentCount;

    @Schema(description = "收款状态", example = "0未收款，1已收款，3坏账")
    private String status;

    @Schema(description = "收款日期")
    private LocalDateTime receiveDate;

    @Schema(description = "收款金额")
    private BigDecimal receiveMoney;

    @Schema(description = "发票号")
    private String receiptCode;

    @Schema(description = "已收金额")
    private BigDecimal alreadyReceiveMoney;

    @Schema(description = "对应服务期")
    private String serviceTerm;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "坏账原因")
    private String badDebtReason;

    @Schema(description = "是否生效", example = "1")
    private String isValid;

    @Schema(description = "坏账日期")
    private LocalDateTime badDebtDate;

    @Schema(description = "经手人", example = "芋艿")
    private String recorderName;

    @Schema(description = "收款内容")
    private String content;

    @Schema(description = "开票状态", example = "1已开票，2作废，3待开票，4不开票")
    private String taxStatus;

    @Schema(description = "开票资料")
    private String taxFile;

    @Schema(description = "签收回执")
    private String signFile;

    @TableField(exist = false)
    @Schema(description = "合同信息")
    private ContractArchiveDO contractArchiveInfo;

    @TableField(exist = false)
    @Schema(description = "收款日期数组（开始时间-结束时间，查询用")
    private List<String> receiveDateStr;


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;


    @TableField(exist = false)
    @Schema(description = "打款记录")
    private List<SanBizPaymentManagement> payment;

    @TableField(exist = false)
    @Schema(description = "发票记录")
    private List<SanBizInvoiceManagement> invoice;

    @TableField(exist = false)
    @Schema(description = "合同编号")
    private String contractCode;

    @TableField(exist = false)
    @Schema(description = "合同名称")
    private String contractName;

    @TableField(exist = false)
    @Schema(description = "合同类型")
    private String contractType;

    @TableField(exist = false)
    @Schema(description = "乙方负责人（签约人）")
    private String companyDirectorName;

    @TableField(exist = false)
    @Schema(description = "签约时间")
    private LocalDateTime signTime;

    @TableField(exist = false)
    @Schema(description = "客户名称")
    private String customerName;

    /**
     * 创建者
     */
    @Schema(description = "创建者")
    private String creator;


    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private Date createTime;

    /**
     * 更新者
     */
    @Schema(description = "更新者")
    private String updater;

    /**
     * 更新时间
     */
    @Schema(description = "更新时间")
    private Date updateTime;

    /**
     * 是否删除
     */
    @Schema(description = "是否删除")
    private Boolean deleted;

    /**
     * 租户ID
     */
    @Schema(description = "租户ID")
    private Long tenantId;

    @Schema(description = "收款管理中是否可选择此合同")
    @TableField(exist = false)
    private Boolean disabled;

    @Schema(description = "发票管理中是否可选择此合同")
    @TableField(exist = false)
    private Boolean disabledInvoice;


}